package com.codelab.statemachine.config;

import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.guard.Guard;

public class ComplexFormDealChoiceGuard implements Guard<ComplexFormStates, ComplexFormEvents> {
    @Override
    public boolean evaluate(StateContext<ComplexFormStates, ComplexFormEvents> stateContext) {
        System.out.println("ComplexFromDealChoiceGuard!!!!!!!!!");
        boolean returnValue = false;
        Form form = stateContext.getMessage().getHeaders().get("form",Form.class);
        if(form.formName==null || form.formName.indexOf("坏")>-1){
            returnValue = false;
        }else {
            returnValue = true;
        }

        System.out.println(form.toString()+"is "+returnValue);
        return returnValue;
    }
}
